﻿// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

//变量类型 变量名=复制
#region 变量
int i = 10;
Console.WriteLine(i);
#endregion

#region 常量
const int a = 10;
Console.WriteLine(a);
#endregion

#region 转义字符
string str = "\'sfes\'";
Console.WriteLine("单引号：" + str);
str = "\"aaaa\"";
Console.WriteLine("双引号：" + str);
str = "aa\\";
Console.WriteLine("单斜杠：" + str);
str = "aa\ta";
Console.WriteLine("tab空格：" + str);
//取消转义字符
string stri = @"sf\sfsf";
Console.WriteLine(stri);
#endregion

#region 变量类型转换



//隐式转换
//大范围转小范围
long aa = 1;//大
int bb = 1;//小
aa = bb;
//浮点型可装任意整形数字=>高精度装低精度
float f;
long cc = 1;//大
f = cc;
//显示转换
//括号强转=>不写了
//Parse=>用来转换字符串
int i1 = int.Parse("511");
Console.WriteLine(i1);
//511
//Convert
//Convert.To目标类型(待转字符);
int i2 = Convert.ToInt32("5456");
Console.WriteLine(i2);
//5436
i2 = Convert.ToInt32(false);
Console.WriteLine(i2);
//0
//其他类型转换为字符串
string str1 = 1.ToString();
Console.WriteLine(str1);
str1 = false.ToString();
Console.WriteLine(str1);

#endregion

#region 异常处理
//过
#endregion

#region 算数运算符
//过
#endregion

#region 字符串拼接
string str2;
str2 = string.Format("fsf{0},sf{2},sgsg{1}", '0', '1', '2');
Console.WriteLine(str2);
#endregion

#region for循环
for (int v = 0; v <= 10; ++v)
{
    Console.WriteLine(v);
}
#endregion
